﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_DLL.Product.database;

namespace ERP_RORZE_PRODUCT.Product.BasicList
{
    public partial class frm_OptionEdit : DevExpress.XtraEditors.XtraForm
    {
        public event EventHandler Reload;
        ClsBasicListDAO clsBasiclistDAO = new ClsBasicListDAO();
        ClsOptionTable b = new ClsOptionTable();
        public string OptionID;
        public string OptionName;
        public string Labor;

        public frm_OptionEdit()
        {
            InitializeComponent();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtOptionID.Text == "")
            {
                MessageBox.Show("Chưa nhập OptionID");
            }
            else if (txtOptionName.Text == "")
            {
                MessageBox.Show("Chưa nhập OptionName");
            }
            else
            {
                b.OptionID = txtOptionID.Text;
                b.OptionName = txtOptionName.Text;
                b.Labor = checkLabor.Checked;

                clsBasiclistDAO.UpdateOption(b);
                Reload(sender, e);
            }
        }

        private void frm_OptionEdit_Load(object sender, EventArgs e)
        {
            txtOptionID.Text = OptionID;
            txtOptionName.Text = OptionName;
            checkLabor.Checked = bool.Parse(Labor);
        }
    }
}